package edu.arizona.sista.learn.activity.fluents.paths;

public class Vec3D {
	private double x, y, z;
	
	public Vec3D() {
		this(0, 0, 0);
	}
	
	public Vec3D(String x, String y, String z) {
		this(Double.parseDouble(x), Double.parseDouble(y), Double.parseDouble(z));
	}
	
	public Vec3D(double x, double y, double z) {
		setX(x);
		setY(y);
		setZ(z);
	}
	
	public Vec3D(Point3D pt1, Point3D pt2) {
		this(pt2.getX()-pt1.getX(), pt2.getY()-pt1.getY(), pt2.getZ()-pt1.getZ());
	}
	
	@Override
	public String toString() {
		return "<Vec3D(" + x + ", " + y + ", " + z + ")>";
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getX() {
		return x;
	}

	public void setY(double y) {
		this.y = y;
	}

	public double getY() {
		return y;
	}

	public void setZ(double z) {
		this.z = z;
	}

	public double getZ() {
		return z;
	}
	
	public double dot(Vec3D other) {
		return (x*other.getX())+(y*other.getY())+(z*other.getZ());
	}
	
	public double magnitude() {
		return Math.sqrt(x*x+y*y+z*z);
	}
	
	public double angle(Vec3D other) {
		return Math.acos(this.dot(other)/(this.magnitude()*other.magnitude()));
	}
}
